     

************************************************************************************************************
************************************************************************************************************
******* Table 5 & Table 6		****************************************************************************
************************************************************************************************************
************************************************************************************************************


set more off
use  "${data}Panel_quarterly.dta", replace

keep if analysis_sample==1

gen year=quarter/4

label variable year "Spell time (year)"
label variable explained_monthly_w  "Targeted monthly wage"
label variable Avg_weekly_hours_month "Targeted weekly hours"
label variable explained_hourly_w "Targeted hourly wage"
label variable Avg_w_rome_month "Mean hourly wage in targeted occupation"
label variable Avg_w_within_rome "Targeted wage relative to occupation mean"
label variable Avg_above_qualif0 "Proportion applied jobs matching own skills (or above)"
label variable Avg_above_educ0   "Proportion applied jobs matching own education (or above)"
label variable Avg_permcont_month "Proportion applied jobs with open-ended contract"

foreach var of varlist  quarter_* {
gen low_`var'= `var'==1 & low_wage==1
}

		


************************************************************************************************************
******* Table 5 Upper Panel		  **************************************************************************
************************************************************************************************************


global cond " if no_missing_wage ==1"

set more off
xi : reghdfe ln_explained_monthly_w ${MainQTE} ${OtherQTE} ${SpellTimeFE}   				${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
su explained_monthly_w ${cond},   d
local A=round(r(mean), 0.001)
di `A'
		estadd local Mean `A'
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_0
xi : reghdfe ln_actual_weekly_hours ${MainQTE} ${OtherQTE} ${SpellTimeFE}   				${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
su Avg_weekly_hours_month ${cond},   d
local A=round(r(mean), 0.001)
di `A'
		estadd local Mean `A'
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_1
xi : reghdfe ln_explained_hourly_w ${MainQTE} ${OtherQTE} ${SpellTimeFE}   					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
su explained_hourly_w ${cond},   d
local A=round(r(mean), 0.001)
di `A'
		estadd local Mean `A'
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_2
xi : reghdfe ln_Avg_w_rome_month ${MainQTE} ${OtherQTE} ${SpellTimeFE}   					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
su Avg_w_rome_month ${cond},   d
local A=round(r(mean), 0.001)
di `A'
		estadd local Mean `A'
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_3
xi : reghdfe  ln_Avg_w_within_rome ${MainQTE} ${OtherQTE} ${SpellTimeFE}   					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
su Avg_w_within_rome ${cond},   d
local A=round(r(mean), 0.001)
di `A'
		estadd local Mean `A'
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_4
xi : reghdfe Avg_above_qualif0 ${MainQTE} ${OtherQTE} ${SpellTimeFE}   					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
su Avg_above_qualif0 ${cond},   d
local A=round(r(mean), 0.001)
di `A'
		estadd local Mean `A'
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_5
xi : reghdfe Avg_above_educ0 ${MainQTE} ${OtherQTE} ${SpellTimeFE}   				${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
su Avg_above_educ0 ${cond},   d
local A=round(r(mean), 0.001)
di `A'
		estadd local Mean `A'
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_6
xi : reghdfe Avg_permcont_month ${MainQTE} ${OtherQTE} ${SpellTimeFE}   					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (quarter_to_exhaustion_plus3:_b[quarter_to_exhaustion_plus3] ) (quarter_to_exhaustion_plus2:_b[quarter_to_exhaustion_plus2] ) (quarter_to_exhaustion_plus1:_b[quarter_to_exhaustion_plus1] ) (quarter_to_exhaustion_0:_b[quarter_to_exhaustion_0] ) (quarter_to_exhaustion_minus1:_b[quarter_to_exhaustion_minus1]) (quarter_to_exhaustion_minus2:_b[quarter_to_exhaustion_minus2]) (quarter_to_exhaustion_minus3:_b[quarter_to_exhaustion_minus3]) (quarter_to_exhaustion_minus4:_b[quarter_to_exhaustion_minus4] )  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
su Avg_permcont_month ${cond},   d
local A=round(r(mean), 0.001)
di `A'
		estadd local Mean `A'
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_7

******* Latex Table:

estout m_0 m_1 m_2 m_3 m_4 m_5 m_6 m_7   using "${path}Table5_upper",  ///
keep ( Average) order (Average ) varlabel(Average "$ T$ to $ T+4$")  ///
stats( SpellTimeFE SpellFE N Mean, labels("Spell time FE" "Spell FE" "No. of Obs" "Mean (no log)") fmt( %9.3f %9.3f %9.0fc  %9.3f)) ///
style(tex) cells( b(star fmt(3)) se(par fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010) ///
mgroups(" " "Source of variation in target wage" "Match quality" "Job quality", pattern(1 1 0 0 0 1 0 1)  prefix(\multicolumn{@span}{c}{) suffix(})   span erepeat(\cmidrule(lr){@span})) ///
 mlabels("\shortstack{Monthly\\wage\\(log)}" "\shortstack{Weekly\\hours\\(log)}" ///
		"\shortstack{Hourly\\wage\\(log)}" "\shortstack{Occupation\\mean hourly\\wage (log)}" "\shortstack{Hourly wage\\ $/$ occupation\\mean (log)}" ///
		"\shortstack{Job requires\\skills\\ $\ge$ worker's}""\shortstack{Job requires\\education\\ $\ge$ worker's}""\shortstack{Open-\\ended\\contract}") /// 
 title("The job quality targeted by unemployed workers around benefits exhaustion")   label legend  replace numbers  collabels(none) 

******* Excel Table:
  
estout  m_0 m_1 m_2 m_3 m_4 m_5 m_6 m_7   using "${path}Table5_upper.xls",  ///
 keep ( Average) order (Average )  varlabel(Average "T to T+4") ///
stats( SpellTimeFE SpellFE N Mean, labels("Spell time FE" "Spell FE" "No. of Obs" "Mean (no log)") fmt( %9.3f %9.3f %9.0fc  %9.3f)) ///
 cells( b(star fmt(3)) se(fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010) ///
mgroups(" " "Source of variation in target wage" "Match quality" "Job quality", pattern(1 1 0 0 0 1 0 1) ) ///
 mlabels("Monthly wage(log)" "Weekly hours (log)" "Hourly wage (log)" "Occupation mean hourly wage (log)" "Hourly wage/occupation mean (log)" ///
		"Job requires skills >= worker's""Job requires education >= worker's" "Open-ended contract") /// 
 title("The job quality targeted by unemployed workers around benefits exhaustion")   label legend  replace    collabels(none) 

  
  

************************************************************************************************************
******* Table 5 Lower Panel		  **************************************************************************
************************************************************************************************************


set more off

global cond " if no_missing_wage ==1 "

xi : reghdfe ln_explained_monthly_w ${MainQTE} ${OtherQTE} ${SpellTimeFE} ${MainQTE_low} ${OtherQTE_low} ${SpellTimeFE_low}    					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (Average_low: (_b[low_quarter_to_exhaustion_0] + _b[low_quarter_to_exhaustion_minus1] + _b[low_quarter_to_exhaustion_minus2]+ _b[low_quarter_to_exhaustion_minus3] + _b[ low_quarter_to_exhaustion_minus4])/5)  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_0
xi : reghdfe ln_actual_weekly_hours ${MainQTE} ${OtherQTE} ${SpellTimeFE}   ${MainQTE_low} ${OtherQTE_low} ${SpellTimeFE_low}  				${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (Average_low: (_b[low_quarter_to_exhaustion_0] + _b[low_quarter_to_exhaustion_minus1] + _b[low_quarter_to_exhaustion_minus2]+ _b[low_quarter_to_exhaustion_minus3] + _b[ low_quarter_to_exhaustion_minus4])/5)  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_1
xi : reghdfe ln_explained_hourly_w ${MainQTE} ${OtherQTE} ${SpellTimeFE}   ${MainQTE_low} ${OtherQTE_low} ${SpellTimeFE_low}  					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (Average_low: (_b[low_quarter_to_exhaustion_0] + _b[low_quarter_to_exhaustion_minus1] + _b[low_quarter_to_exhaustion_minus2]+ _b[low_quarter_to_exhaustion_minus3] + _b[ low_quarter_to_exhaustion_minus4])/5)  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_2
xi : reghdfe ln_Avg_w_rome_month ${MainQTE} ${OtherQTE} ${SpellTimeFE}   	${MainQTE_low} ${OtherQTE_low} ${SpellTimeFE_low}  				${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (Average_low: (_b[low_quarter_to_exhaustion_0] + _b[low_quarter_to_exhaustion_minus1] + _b[low_quarter_to_exhaustion_minus2]+ _b[low_quarter_to_exhaustion_minus3] + _b[ low_quarter_to_exhaustion_minus4])/5)  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_3
xi : reghdfe ln_Avg_w_within_rome ${MainQTE} ${OtherQTE} ${SpellTimeFE}   ${MainQTE_low} ${OtherQTE_low} ${SpellTimeFE_low}  					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (Average_low: (_b[low_quarter_to_exhaustion_0] + _b[low_quarter_to_exhaustion_minus1] + _b[low_quarter_to_exhaustion_minus2]+ _b[low_quarter_to_exhaustion_minus3] + _b[ low_quarter_to_exhaustion_minus4])/5)  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_4
xi : reghdfe Avg_above_qualif0 ${MainQTE} ${OtherQTE} ${SpellTimeFE}   ${MainQTE_low} ${OtherQTE_low} ${SpellTimeFE_low}  				${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (Average_low: (_b[low_quarter_to_exhaustion_0] + _b[low_quarter_to_exhaustion_minus1] + _b[low_quarter_to_exhaustion_minus2]+ _b[low_quarter_to_exhaustion_minus3] + _b[ low_quarter_to_exhaustion_minus4])/5)  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_5
xi : reghdfe Avg_above_educ0 ${MainQTE} ${OtherQTE} ${SpellTimeFE}  ${MainQTE_low} ${OtherQTE_low} ${SpellTimeFE_low}   					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (Average_low: (_b[low_quarter_to_exhaustion_0] + _b[low_quarter_to_exhaustion_minus1] + _b[low_quarter_to_exhaustion_minus2]+ _b[low_quarter_to_exhaustion_minus3] + _b[ low_quarter_to_exhaustion_minus4])/5)  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_6
xi : reghdfe Avg_permcont_month ${MainQTE} ${OtherQTE} ${SpellTimeFE}   	${MainQTE_low} ${OtherQTE_low} ${SpellTimeFE_low}  				${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
nlcom  (Average_low: (_b[low_quarter_to_exhaustion_0] + _b[low_quarter_to_exhaustion_minus1] + _b[low_quarter_to_exhaustion_minus2]+ _b[low_quarter_to_exhaustion_minus3] + _b[ low_quarter_to_exhaustion_minus4])/5)  (Average: (_b[quarter_to_exhaustion_0] + _b[quarter_to_exhaustion_minus1] + _b[quarter_to_exhaustion_minus2]+ _b[quarter_to_exhaustion_minus3] + _b[ quarter_to_exhaustion_minus4])/5)  , post
		estadd local SpellFE "Yes"
		estadd local SpellTimeFE "Yes"
est store  m_7

******* Latex Table:

estout m_0 m_1 m_2 m_3 m_4 m_5 m_6 m_7   using "${path}Table5_lower",  ///
keep ( Average Average_low) order (Average Average_low) varlabel(Average "$ T$ to $ T+4$" Average_low "$ T$ to $ T+4$ $*$Low wage ") ///
stats( PBDFE SpellTimeFE SpellFE N, labels(   "PBD-group FE" "Spell time FE" "Spell FE" "No. of Obs") fmt(%9.3f %9.3f %9.3f %9.0fc )) ///
style(tex) cells( b(star fmt(3)) se(par fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010) ///
 label legend  replace numbers mlabels(none)   collabels(none) 

******* Excel Table:
  
estout  m_0 m_1 m_2 m_3 m_4 m_5 m_6 m_7   using "${path}Table5_lower.xls",  ///
 keep ( Average Average_low) order (Average Average_low)  varlabel(Average "T to T+4" Average_low "T to T+4 *Low wage") ///
 stats( PBDFE SpellTimeFE SpellFE N, labels(   "PBD-group FE" "Spell time FE" "Spell FE" "No. of Obs") fmt(%9.3f %9.3f %9.3f %9.0fc )) ///
 mgroups(" " "Source of variation in target wage" "Match quality" "Job quality", pattern(1 1 0 0 0 1 0 1) ) ///
 cells( b(star fmt(3)) se(fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010)  label legend append     mlabels(none)   collabels(none) 



************************************************************************************************************
************** TABLE 6 *************************************************************************************
************************************************************************************************************



global cond " if no_missing_wage ==1"

set more off
xi : reghdfe ln_explained_monthly_w ${MainQTE} ${OtherQTE}  c.year					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
		estadd local SpellFE "Yes"
		estadd local TimeToExhaustionFE "Yes"
est store  m_0
xi : reghdfe ln_actual_weekly_hours ${MainQTE} ${OtherQTE}  c.year					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
		estadd local SpellFE "Yes"
		estadd local TimeToExhaustionFE "Yes"
est store  m_1
xi : reghdfe ln_explained_hourly_w ${MainQTE} ${OtherQTE}  c.year					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
		estadd local SpellFE "Yes"
		estadd local TimeToExhaustionFE "Yes"
est store  m_2
xi : reghdfe ln_Avg_w_rome_month ${MainQTE} ${OtherQTE} c.year					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
		estadd local SpellFE "Yes"
		estadd local TimeToExhaustionFE "Yes"
est store  m_3
xi : reghdfe ln_Avg_w_within_rome ${MainQTE} ${OtherQTE} c.year						${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
		estadd local SpellFE "Yes"
		estadd local TimeToExhaustionFE "Yes"
est store  m_4
xi : reghdfe Avg_above_qualif0 ${MainQTE} ${OtherQTE} c.year	  					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
		estadd local SpellFE "Yes"
		estadd local TimeToExhaustionFE "Yes"
est store  m_5
xi : reghdfe Avg_above_educ0 ${MainQTE} ${OtherQTE} c.year					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
		estadd local SpellFE "Yes"
		estadd local TimeToExhaustionFE "Yes"
est store  m_6
xi : reghdfe Avg_permcont_month ${MainQTE} ${OtherQTE} c.year					${cond} ,   	absorb(spell_identifier) cluster(spell_identifier)
		estadd local SpellFE "Yes"
		estadd local TimeToExhaustionFE "Yes"
est store  m_7


******* Latex Table:

estout m_0 m_1 m_2 m_3 m_4 m_5 m_6 m_7   using "${path}Table6",  ///
keep (year)  style(tex) cells( b(star fmt(3)) se(par fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010) ///
stats( SpellFE TimeToExhaustionFE N, labels(  "Spell time FE" "TimeToExhaustionFE" "No. of Obs") fmt(%9.3f %9.3f %9.0fc )) ///
mgroups(" " "Source of variation in target wage" "Match quality" "Job quality", pattern(1 1 0 0 0 1 0 1)  prefix(\multicolumn{@span}{c}{) suffix(})   span erepeat(\cmidrule(lr){@span})) ///
mlabels("\shortstack{Monthly\\wage\\(log)}" "\shortstack{Weekly\\hours\\(log)}" ///
		"\shortstack{Hourly\\wage\\(log)}" "\shortstack{Occupation\\mean hourly\\wage (log)}" "\shortstack{Hourly wage\\ $/$ occupation\\mean (log)}" ///
		"\shortstack{Job requires\\skills\\ $\ge$ worker's}""\shortstack{Job requires\\education\\ $\ge$ worker's}""\shortstack{Open-\\ended\\contract}") /// 
 title(" Duration dependence: The impact of unemployment duration on targeted job quality")   label legend  replace numbers   collabels(none) 

 
******* Excel Table:
  
estout  m_0 m_1 m_2 m_3 m_4 m_5 m_6 m_7   using "${path}Table6.xls",  ///
 keep (year)   ///
stats( SpellFE TimeToExhaustionFE N, labels(  "Spell time FE" "TimeToExhaustionFE" "No. of Obs") fmt(%9.3f %9.3f %9.0fc )) ///
cells( b(star fmt(3)) se(fmt(3)) )   starlevels( * 0.10 ** 0.05 *** 0.010)  ///
mgroups(" " "Source of variation in target wage" "Match quality" "Job quality", pattern(1 1 0 0 0 1 0 1)  ) ///
 mlabels("Monthly wage(log)" "Weekly hours (log)" "Hourly wage (log)" "Occupation mean hourly wage (log)" "Hourly wage/occupation mean (log)" ///
		"Job requires skills >= worker's""Job requires education >= worker's" "Open-ended contract") /// 
 title(" Duration dependence: The impact of unemployment duration on targeted job quality")   label legend  replace   collabels(none) 





